var aiEnableCookie=false; var aiId=''; var aiExtraSpace=0; var aiAccTime=0; var aiOnloadEventsCounter=0; var aiCallbackExists=typeof aiReadyCallbacks!=='undefined'&&aiReadyCallbacks instanceof Array; var aiReadyCallbacks=aiCallbackExists ? aiReadyCallbacks:[]; function aiResizeIframe(obj, resizeWidth, resizeMinHeight){ try { if(obj.contentWindow.location.href==='about:blank'){ return; } if(obj.contentWindow.document.body!=null){ var oldScrollposition=jQuery(window).scrollTop(); obj.style.marginTop=0; obj.style.marginBottom=0; obj.height=Number(resizeMinHeight); obj.style.height=Number(resizeMinHeight) + 'px'; var newheight=aiGetIframeHeight(obj); obj.height=newheight; obj.style.height=newheight + 'px'; if(jQuery('#ai-zoom-div-' + obj.id).length!==0){ var zoom=window['zoom_' + obj.id]; jQuery('#ai-zoom-div-' + obj.id).css('height', newheight * zoom); } if(aiEnableCookie&&aiExtraSpace===0){ aiWriteCookie(newheight); } var hash=aiGetIframeHash(obj.contentWindow.location.href); if(hash!==-1){ var iframeId='#'+ obj.id; try { var hashposition=jQuery(iframeId).contents().find('#'+ hash); if(hashposition.length!==0){ var hashpositionTop=hashposition.offset().top; oldScrollposition=Math.round(jQuery(iframeId).offset().top + hashpositionTop); }} catch(e){ }} setTimeout(function(){ jQuery("html,body").scrollTop(oldScrollposition); }, 50); if(resizeWidth==='true'){ var newWidth=aiGetIframeWidth(obj); obj.width=newWidth; obj.style.width=newWidth + 'px'; } var fCallback=window['resizeCallback' + obj.id]; fCallback(); if(window.frameElement!=null){ parent.jQuery('iframe').trigger('onload'); }}else{ setTimeout(function(){ aiResizeIframe(obj, resizeWidth); },100); }} catch(e){ if(console&&console.log){ console.log('Advanced iframe configuration error: You have enabled the resize of the iframe for pages on the same domain. But you use an iframe page on a different domain. You need to use the external workaround like described in the settings. Also check the next log. There the browser message for this error is displayed.'); console.log(e); }} } function aiGetIframeHash(url){ var hash=url.split('#')[1]; return (hash) ? hash:'-1'; } function aiGetIframeHeight(obj){ var bodyHeight=Math.max(obj.contentWindow.document.body.scrollHeight, obj.contentWindow.document.body.offsetHeight, obj.contentWindow.document.documentElement.scrollHeight, obj.contentWindow.document.documentElement.offsetHeight); var newheight=bodyHeight + aiExtraSpace; return newheight; } function aiGetIframeWidth(obj){ var oldWidth=obj.width; obj.width=1; obj.style.width='1px'; var bodyWidth=Math.max(obj.contentWindow.document.body.scrollWidth, obj.contentWindow.document.body.offsetWidth, obj.contentWindow.document.documentElement.scrollWidth, obj.contentWindow.document.documentElement.offsetWidth); if(bodyWidth!==1){ obj.width=bodyWidth; obj.style.width=bodyWidth + 'px'; }else{ obj.width=oldWidth; obj.style.width=oldWidth + 'px'; } return bodyWidth; } function aiGetParentIframeWidth(obj){ if(obj!=null&&jQuery('#' + obj.id).length!==0){ return jQuery('#' + obj.id).width(); }else{ return -1; }} function aiResizeIframeHeightById(id, nHeight){ try { var fCallback=window['resizeCallback' + id]; fCallback(); var height=parseInt(nHeight,10) + aiExtraSpace; var iframe=document.getElementById(id); var oldScrollposition=jQuery(document).scrollTop(); iframe.height=height; iframe.style.height=height + 'px'; jQuery("html,body").scrollTop(oldScrollposition); if(aiEnableCookie&&aiExtraSpace===0){ aiWriteCookie(height); } var parentResizeCall=window['aiExecuteWorkaround_' + id]; if(parentResizeCall!=null){ parentResizeCall(); }} catch(e){ if(console&&console.log){ console.log('Advanced iframe configuration error: The id of the parent and the external workaround are different! Check your settings.'); console.log(e); }} } function aiScrollToTop(id, position){ if(aiOnloadEventsCounter > 0){ var posTop=0; if(position==='iframe'){ posTop=jQuery('#' + id).offset().top; } setTimeout(function(){ window.scrollTo(0, posTop); }, 100); } setTimeout(function(){ aiOnloadEventsCounter++; }, 1000); } function aiWriteCookie(height){ var cookieName='ai-last-height'; if(aiId!==''){ cookieName=cookieName + '-' + aiId ; } var cookieStr=cookieName + '=' + height; document.cookie=cookieStr; } function aiUseCookie(){ var cookieName='ai-last-height'; if(aiId!==''){ cookieName=cookieName + '-' + aiId ; } var allcookies=document.cookie; var cookiearray=allcookies.split(';'); for (var i=0; i < cookiearray.length; i++){ var name=cookiearray[i].split('=')[0]; var value=cookiearray[i].split('=')[1]; if(name===cookieName&&value!==null&&aiIsNumeric(value)){ var iframe=document.getElementById(aiId); iframe.height=parseInt(value,10); iframe.style.height=value + 'px'; }} } function aiIsNumeric(input){ return !isNaN(input); } function aiDisableHeight(){ jQuery('#additional_height').attr('readonly','readonly'); jQuery('#additional_height').val('0'); } function aiEnableHeight(){ jQuery('#additional_height').removeAttr('readonly'); } function aiShowElementOnly(iframeId, showElement){ try { var iframe=jQuery(iframeId).contents().find('body'); var selectedBox=iframe.find(showElement).clone(true,true); iframe.find('*').not(jQuery('script')).remove(); iframe.prepend(selectedBox); } catch(e){ if(console&&console.log){ console.log('Advanced iframe configuration error: You have enabled to show only one element of the iframe for pages on the same domain. But you use an iframe page on a different domain. You need to use the pro version of the external workaround like described in the settings. Also check the next log. There the browser message for this error is displayed.'); console.log(e); }} } function aiCheckIfValidTarget(evt, elements){ var targ; if(!evt){ evt=window.event; } if(evt.target){ targ=evt.target; }else if(evt.srcElement){ targ=evt.srcElement; } if(targ.nodeType===3){ targ=targ.parentNode; } var parts=elements.split(','); for (var i=0; i< parts.length; ++i){ var selectorArray=parts[i].split(':'); if(selectorArray[0].toLowerCase()===targ.nodeName.toLowerCase()){ if(selectorArray.length > 1){ if(targ.id.toLowerCase().indexOf(selectorArray[1].toLowerCase())!==-1){ return true; }}else{ return true; }} } return false; } function aiOpenSelectorWindow (url){ var localWidth=jQuery('#width').val(); var localHeight=jQuery('#ai-height-0').val(); if(localWidth.indexOf('%') >=0||Number(localWidth) < 900){ localWidth=900; } localWidth=Number(localWidth) + 40; if(localWidth > (screen.width)){ localWidth=screen.width; } if(localHeight.indexOf('%') >=0){ localHeight=screen.height; }else{ localHeight=Number(localHeight) + 480; } if(localHeight > (screen.height-50)){ localHeight=screen.height-50; } var options='width='+localWidth+',height='+localHeight+',left=0,top=0,resizable=1,scrollbars=1'; var popup_window=window.open(url, '', options); popup_window.focus(); } function aiDisableAiResizeOptions(value){ jQuery('#onload_resize_delay').prop('readonly',value); jQuery('input[id=store_height_in_cookie1]:radio, input[id=store_height_in_cookie2]:radio').attr('disabled',value); jQuery('#additional_height').prop('readonly', value); jQuery('input[id=onload_resize_width1]:radio, input[id=onload_resize_width2]:radio').attr('disabled',value); jQuery('#resize_on_click').prop('readonly', value); jQuery('#resize_on_click_elements').prop('readonly', value); jQuery('#resize_on_ajax').prop('readonly', value); jQuery('input[id=resize_on_ajax_jquery1]:radio, input[id=resize_on_ajax_jquery2]:radio').attr('disabled',value); var selector='#onload_resize_delay, #store_height_in_cookie1, #additional_height, #onload_resize_width1, '; selector +='#resize_on_click, #resize_on_click_elements, #resize_on_ajax, #resize_on_ajax_jquery1'; aiDisableTextSection(value, selector); } function aiDisablePartOfIframeOptions(value){ jQuery('#show_part_of_iframe_x').prop('readonly',value); jQuery('#show_part_of_iframe_y').prop('readonly',value); jQuery('#show_part_of_iframe_height').prop('readonly',value); jQuery('#show_part_of_iframe_width').prop('readonly',value); jQuery('input[id=show_part_of_iframe_allow_scrollbar_horizontal1]:radio, input[id=show_part_of_iframe_allow_scrollbar_horizontal2]:radio').attr('disabled',value); jQuery('input[id=show_part_of_iframe_allow_scrollbar_vertical1]:radio, input[id=show_part_of_iframe_allow_scrollbar_vertical2]:radio').attr('disabled',value); jQuery('#show_part_of_iframe_next_viewports').prop('readonly',value); jQuery('input[id=show_part_of_iframe_next_viewports_loop1]:radio, input[id=show_part_of_iframe_next_viewports_loop2]:radio').attr('disabled',value); jQuery('#show_part_of_iframe_new_window').prop('readonly',value); jQuery('#show_part_of_iframe_new_url').prop('readonly',value); jQuery('input[id=show_part_of_iframe_next_viewports_hide1]:radio, input[id=show_part_of_iframe_next_viewports_hide2]:radio').attr('disabled',value); jQuery('#show_part_of_iframe_style').prop('readonly',value); jQuery('input[id=show_part_of_iframe_zoom1]:radio, input[id=show_part_of_iframe_zoom2]:radio, input[id=show_part_of_iframe_zoom3]:radio').attr('disabled',value); jQuery('.media-query-input').prop('readonly',value); var selector='#show_part_of_iframe_x, #show_part_of_iframe_y, #show_part_of_iframe_height, #show_part_of_iframe_width, '; selector +='#show_part_of_iframe_allow_scrollbar_horizontal1, #show_part_of_iframe_next_viewports, #show_part_of_iframe_next_viewports_loop1, '; selector +='#show_part_of_iframe_new_window, #show_part_of_iframe_new_url, #show_part_of_iframe_next_viewports_hide1, #show_part_of_iframe_style, '; selector +='#show_part_of_iframe_zoom1, #show_part_of_iframe_allow_scrollbar_vertical1, #add-media-query-show_part_of_iframe_media_query'; aiDisableTextSection(value, selector); if(value){ jQuery('#add-media-query-show_part_of_iframe_media_query').hide(); jQuery('.ai-delete').hide(); }else{ jQuery('#add-media-query-show_part_of_iframe_media_query').show(); jQuery('.ai-delete').show(); }} function aiDisableLazyLoadOptions(value){ jQuery('#enable_lazy_load_threshold').prop('readonly', value); jQuery('#enable_lazy_load_fadetime').prop('readonly', value); jQuery('input[id=enable_lazy_load_reserve_space1]:radio, input[id=enable_lazy_load_reserve_space2]:radio').attr('disabled',value); jQuery('input[id=enable_lazy_load_manual1]:radio, input[id=enable_lazy_load_manual2]:radio, input[id=enable_lazy_load_manual3]:radio').attr('disabled',value); var selector='#enable_lazy_load_threshold, #enable_lazy_load_fadetime, #enable_lazy_load_reserve_space1, #enable_lazy_load_manual1'; aiDisableTextSection(value, selector); } function aiDisableIframeAsLayerOptions(value){ jQuery('input[id=show_iframe_as_layer_full]:radio').attr('disabled',value); jQuery('#show_iframe_as_layer_header_file').prop('readonly', value); jQuery('#show_iframe_as_layer_header_height').prop('readonly', value); jQuery('input[id=show_iframe_as_layer_header_position1]:radio, input[id=show_iframe_as_layer_header_position2]:radio').attr('disabled',value); jQuery('input[id=show_iframe_as_layer_full1]:radio, input[id=show_iframe_as_layer_full2]:radio, input[id=show_iframe_as_layer_full3]:radio').attr('disabled',value); jQuery('input[id=show_iframe_as_layer_keep_content1]:radio, input[id=show_iframe_as_layer_keep_content2]:radio').attr('disabled',value); var selector='#show_iframe_as_layer_full, #show_iframe_as_layer_header_file, #show_iframe_as_layer_header_height, '; selector +='#show_iframe_as_layer_header_position1, #show_iframe_as_layer_full1, #show_iframe_as_layer_keep_content1'; aiDisableTextSection(value, selector); } function aiDisableTextSection(value, selector){ if(value){ jQuery(selector).closest('tr').addClass('disabled'); }else{ jQuery(selector).closest('tr').removeClass('disabled'); }} var aiInstance; function aiInitAdminConfiguration(isPro, acc_type){ if(jQuery('input[type=radio][name=onload_resize]:checked').val()==='false'){ aiDisableAiResizeOptions(true); } jQuery('input[type=radio][name=onload_resize]').click(function(){ if(jQuery(this).val()==='true'){ jQuery('input:radio[name=enable_external_height_workaround]')[1].checked=true; aiDisableAiResizeOptions(false); }else{ jQuery('#onload_resize_delay').val(''); aiDisableAiResizeOptions(true); }}); jQuery('input[type=radio][name=enable_external_height_workaround]').click(function(){ if(jQuery(this).val()==='true'){ jQuery('input:radio[name=onload_resize]')[1].checked=true; jQuery('#onload_resize_delay').val(''); aiDisableAiResizeOptions(true); }}); if(jQuery('input[type=radio][name=show_part_of_iframe]:checked').val()==='false'){ aiDisablePartOfIframeOptions(true); } jQuery('input[type=radio][name=show_part_of_iframe]').click(function(){ if(jQuery(this).val()==='false'){ aiDisablePartOfIframeOptions(true); }else{ aiDisablePartOfIframeOptions(false); }}); if(jQuery('input[type=radio][name=show_iframe_as_layer]:checked').val()==='false'){ aiDisableIframeAsLayerOptions(true); } jQuery('input[type=radio][name=show_iframe_as_layer]').click(function(){ if(jQuery(this).val()==='false'){ aiDisableIframeAsLayerOptions(true); }else{ aiDisableIframeAsLayerOptions(false); }}); if(jQuery('input[type=radio][name=expert_mode]:checked').val()==='true'){ jQuery('.description').css('display','none'); jQuery('table.form-table th').css('cursor','pointer'); jQuery('table.form-table th').css('padding-top','8px').css('padding-bottom','2px'); jQuery('table.form-table td').css('padding-top','5px').css('padding-bottom','5px'); jQuery('table.form-table th').click(function(){ jQuery('.description').css('display','none'); jQuery('.description', jQuery(this).parent()).css('display','block'); }); } jQuery('input[type=radio][name=expert_mode]').click(function(){ if(jQuery(this).val()==='false'){ jQuery('.description').css('display','block'); jQuery('table.form-table th').css('cursor','auto'); jQuery('table.form-table th').off('click'); jQuery('table.form-table th').css('padding-top','20px').css('padding-bottom','20px'); jQuery('table.form-table td').css('padding-top','15px').css('padding-bottom','15px'); }else{ jQuery('.description').css('display','none'); jQuery('table.form-table th').css('cursor','pointer'); jQuery('table.form-table th').css('padding-top','8px').css('padding-bottom','2px'); jQuery('table.form-table td').css('padding-top','5px').css('padding-bottom','5px'); jQuery('table.form-table th').click(function(){ jQuery('.description').css('display','none'); jQuery('.description', jQuery(this).parent()).css('display','block'); }); }}); jQuery('#accordion').find('h1').click(function(){ jQuery(this).next().slideToggle(aiAccTime); }).next().hide(); jQuery('#accordion').find('a').click(function(){ var hash=jQuery(this).prop('hash'); var hash_only='#h1-' + hash.substring(1); jQuery(hash_only).next().show(); location.hash=hash_only; }); if(jQuery('input[type=radio][name=enable_lazy_load_manual]:checked').val()==='false'){ jQuery('#enable_lazy_load_manual_element').prop('readonly',true); } jQuery('input[type=radio][name=enable_lazy_load_manual]').click(function(){ if(jQuery(this).val()==='false'||jQuery(this).val()==='auto'){ jQuery('#enable_lazy_load_manual_element').prop('readonly',true); }else{ jQuery('#enable_lazy_load_manual_element').prop('readonly',false); }}); if(jQuery('input[type=radio][name=enable_lazy_load]:checked').val()==='false'){ aiDisableLazyLoadOptions(true); jQuery('#enable_lazy_load_manual_element').prop('readonly',true); } jQuery('input[type=radio][name=enable_lazy_load]').click(function(){ if(jQuery(this).val()==='false'){ aiDisableLazyLoadOptions(true); jQuery('#enable_lazy_load_manual_element').prop('readonly',true); }else{ aiDisableLazyLoadOptions(false); if(jQuery('input[type=radio][name=enable_lazy_load_manual]:checked').val()==='false' || jQuery('input[type=radio][name=enable_lazy_load_manual]:checked').val()==='auto'){ jQuery('#enable_lazy_load_manual_element').prop('readonly',true); }else{ jQuery('#enable_lazy_load_manual_element').prop('readonly', false); }} }); jQuery('.confirmation').on('click', function (){ return confirm('Are you sure? Selecting OK will set all settings to the default.'); }); jQuery('a.post').click(function(e){ e.stopPropagation(); e.preventDefault(); var href=this.href; var parts=href.split('?'); var url=parts[0]; var params=parts[1].split('&'); var pp, inputs=''; url +='?' + params[0]; for(var i=1, n=params.length; i < n; i++){ pp=params[i].split('='); inputs +=''; } jQuery('body').append('
'+inputs+'
'); jQuery('#poster').submit(); }); jQuery('.ai-input-search').keyup(function(e){ var searchTerm=jQuery('input.ai-input-search').val().toLowerCase(); aiSettingsSearch(searchTerm, acc_type); }); jQuery('.ai-input-search').on('click', function(e){ setTimeout(function(){ var searchTerm=jQuery('input.ai-input-search').val().toLowerCase(); aiSettingsSearch(searchTerm, acc_type); }, 100); }); jQuery(document).on('click', '.nav-tab-wrapper a', function(){ var current_tab=jQuery(this).attr('id'); jQuery('section').hide(); jQuery('section.' + current_tab).show(); jQuery('#current_tab').val(current_tab.substr(4,1)); jQuery('.nav-tab').removeClass('nav-tab-active'); jQuery(this).addClass('nav-tab-active'); jQuery(this).blur(); return false; }); jQuery(document).on('click', 'a#external-workaround-link', function(){ jQuery('.external-workaround').click(); location.hash='tab_3'; aiShowHeader('tab_3'); return false; }); jQuery(document).on('click', 'a#resize-same-link', function(){ jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-resize').removeClass('closed'); location.hash='id-advanced-resize'; aiShowHeader('id-advanced-resize'); return false; }); jQuery(document).on('click', 'a.jquery-help-link', function(){ jQuery('.help-tab').click(); jQuery('#id-help-jquery').removeClass('closed'); jQuery('#jquery-help').show(); location.hash='id-help-jquery'; aiShowHeader('id-help-jquery'); return false; }); jQuery(document).on('click', 'a#browser-detection-link', function(){ jQuery('.help-tab').click(); jQuery('#id-help-browser').removeClass('closed'); jQuery('#browser-help').show(); location.hash='id-help-browser'; aiShowHeader('id-help-browser'); return false; }); jQuery(document).on('click', 'a.howto-id-link', function(){ jQuery('.help-tab').click(); jQuery('#id-help-id').removeClass('closed'); location.hash='id-help-id'; aiShowHeader('id-help-id'); return false; }); jQuery(document).on('click', '.modifycontent-link', function(){ jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-modify-iframe').removeClass('closed'); location.hash='id-advanced-modify-iframe'; aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); return false; }); jQuery(document).on('click', '.id-modify-css-iframe-link', function(){ jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-modify-iframe').removeClass('closed'); location.hash='id-modify-css-iframe'; aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); return false; }); jQuery(document).on('click', '.modify-target', function(){ jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-modify-iframe').removeClass('closed'); location.hash='id-modify-target'; aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); return false; }); jQuery(document).on('click', 'a.link-external-domain', function(){ jQuery('#id-external-different').removeClass('closed'); location.hash='#id-external-different'; aiShowHeader('id-external-different'); return false; }); jQuery(document).on('click', 'a.link-id-external-ai-config-post', function(){ jQuery('#id-external-ai-config-post').removeClass('closed'); location.hash='#id-external-ai-config-post'; aiShowHeader('id-external-ai-config-post', 'tr-use_post_message'); return false; }); jQuery(document).on('click', 'a.link-id-external-ai-overview', function(){ jQuery('#id-external-ai-overview').removeClass('closed'); location.hash='#id-external-ai-overview'; aiShowHeader('id-external-ai-overview', 'id-external-ai-overview'); return false; }); jQuery(document).on('click', 'a.post-message-help-link', function(){ jQuery('.help-tab').click(); jQuery('#id-help-communication').removeClass('closed'); location.hash='#id-help-communication'; aiShowHeader('id-help-communication','id-help-communication'); return false; }); jQuery(document).on('click', 'a.enable-admin', function(){ jQuery('.options-tab').click(); jQuery('#id-options-display').removeClass('closed'); location.hash='#id-options-display'; aiShowHeader('id-options-display', 'tr-demo'); return false; }); jQuery(document).on('click', 'a#user-help-link', function(){ jQuery('#user-help').css('display', 'block'); return false; }); jQuery(document).on('click', 'a#user-meta-link', function(){ jQuery('#meta-help').css('display', 'block'); return false; }); jQuery(document).on('click', '#ai-selector-help-link', function(){ jQuery('#ai-selector-help').slideDown(1000); return false; }); jQuery(document).on('click', '.ai-selector-help-link-move', function(){ jQuery('#ai-selector-help').show('slow'); location.hash='#ai-selector-help-link'; aiShowHeader('ai-selector-help-link'); return false; }); jQuery('#ai_form').submit(function(){ aiSetScrollposition(); }); jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); if(typeof postboxes!=='undefined'){ postboxes.add_postbox_toggles('toplevel_page_advanced-iframe'); } jQuery('.ai-spinner').css('display','none'); jQuery("#" + acc_type).next().show(); jQuery(document).on('click', '#test-pro-admin.is-permanent-closable button', function(){ closeInfoPermanent('test-pro-admin'); }); jQuery(document).on('click', '.mq-breakpoint-height a', function(evt){ jQuery(this).parent().remove(); aiUpdateHeightHiddenField('height'); evt.preventDefault(); return false; }); jQuery(document).on('click', 'a#add-media-query-height', function(evt){ var nextNr=jQuery(".mq-breakpoint-height").length + 1; jQuery(this).parent().append('
' + '  Breakpoint: ' + '' + 'Delete'); evt.preventDefault(); return false; }); jQuery(document).on('click', '.mq-breakpoint-show_part_of_iframe_media_query a', function(evt){ jQuery(this).parent().remove(); aiUpdateHeightHiddenFieldMediaQuery('show_part_of_iframe_media_query'); evt.preventDefault(); return false; }); jQuery(document).on('click', 'a#add-media-query-show_part_of_iframe_media_query', function(evt){ var nextNr=jQuery(".mq-breakpoint-show_part_of_iframe_media_query").length + 1; jQuery(this).parent().append('
' + 'x: ' + '  y: '+ '  w: '+ '  h: '+ '  iframe width: '+ '  Breakpoint: ' + 'Delete'); evt.preventDefault(); return false; }); } function aiCheckHeightNumber(element, id){ aiCheckInputNumber(element); aiUpdateHeightHiddenField(id); } function aiCheckHeightNumberMediaQuery(element, id){ aiCheckInputNumber(element); aiUpdateHeightHiddenFieldMediaQuery(id); } function aiUpdateHeightHiddenField(id){ var heightDefault=jQuery('#ai-'+id+'-0').val(); var breakpoints=[]; jQuery('.mq-breakpoint-'+id).each(function(index){ var heightChild=jQuery(this).children().eq(0).val(); var breakpointChild=jQuery(this).children().eq(1).val(); if(heightChild!==''&&breakpointChild!==''){ breakpoints.push({ heightChild: heightChild, breakpointChild: breakpointChild }); }}); breakpoints.sort(function(a, b){ return b.breakpointChild - a.breakpointChild; }); let output=heightDefault; breakpoints.forEach(function(element){ output +=',' + element.heightChild + '|' + element.breakpointChild; }); jQuery('#'+id).val(output); const newVal=jQuery('#description-'+id).html().split('Shortcode attribute: ')[0]; jQuery('#description-'+id).html(newVal + 'Shortcode attribute: ' + id + '="' + output + '"'); } function aiUpdateHeightHiddenFieldMediaQuery(id){ var breakpoints=[]; jQuery('.mq-breakpoint-'+id).each(function(index){ var mediaX=jQuery(this).children().eq(0).val(); var mediaY=jQuery(this).children().eq(1).val(); var mediaW=jQuery(this).children().eq(2).val(); var mediaH=jQuery(this).children().eq(3).val(); var mediaIW=jQuery(this).children().eq(4).val(); var breakpointChild=jQuery(this).children().eq(5).val(); if((mediaX!==''||mediaY!==''||mediaW!==''||mediaH!==''||mediaIW!=='') && breakpointChild!==''){ breakpoints.push({ mediaX: mediaX, mediaY: mediaY, mediaW: mediaW, mediaH: mediaH, mediaIW: mediaIW, breakpointChild: breakpointChild }); }}); breakpoints.sort(function(a, b){ return b.breakpointChild - a.breakpointChild; }); let output=''; breakpoints.forEach(function(element){ output +=',' + element.mediaX + '|' + element.mediaY + '|' + element.mediaW + '|' + element.mediaH + '|' + element.mediaIW + '|' + element.breakpointChild }); output=output.replace(/(^,)|(,$)/g, ""); jQuery('#'+id).val(output); const newVal=jQuery('#description-'+id).html().split('Shortcode attribute: ')[0]; jQuery('#description-'+id).html(newVal + 'Shortcode attribute: ' + id + '="' + output + '"'); } function aiSettingsSearch(searchTerm, accType){ var found=0; if(searchTerm!==''){ jQuery('#ai p').not('.form-table p').hide(); jQuery('#ai ul').not('.form-table ul').hide(); jQuery('#ai ol').not('.form-table ol').hide(); if(accType!=='false'){ jQuery('#ai h1').not('.show-always').hide(); jQuery('#ai #accordion').attr('id','acc'); jQuery('#ai #acc > div').show(); jQuery('#ai #spacer-div').show(); } jQuery('#ai h2,#ai .icon_ai,#ai h3,#ai h4').not('.show-always').hide(); jQuery('#ai .form-table').addClass('ai-remove-margin'); jQuery('#ai hr, .signup_account_container, .config-file-block').hide(); jQuery('#ai .hide-always').hide(); jQuery('#ai .hide-search').hide(); jQuery('#ai .postbox-container').not('.show-always').hide(); }else{ jQuery('#ai p').not('.form-table p').show(); jQuery('#ai section .ai-anchor').show(); jQuery('#ai ul').not('.form-table ul').show(); jQuery('#ai ol').not('.form-table ol').show(); if(accType!=='false'){ jQuery('#ai h1').not('.show-always').show(); jQuery('#ai #acc').attr('id','accordion'); jQuery('#ai #accordion > div').hide(); jQuery('#ai #spacer-div').hide(); } jQuery('#ai h2,#ai .icon_ai,#ai h3,#ai h4').not('.show-always').show(); jQuery('#ai .form-table').removeClass('ai-remove-margin'); jQuery('#ai hr, .signup_account_container, .config-file-block').show(); jQuery('#ai .sub-domain-container').show(); jQuery('#ai .hide-search').show(); jQuery('#ai .hide-always').hide(); jQuery('#ai .postbox-container').show(); setTimeout(function(){ jQuery('#ai .postbox-container .closed .inside').css('display', ''); }, 5); } jQuery('#ai .mark-tab-header').removeClass('mark-tab-header'); var firstHit=''; jQuery('#ai tr').each(function(){ var $this=jQuery(this); var valueLabel=$this.find('th').text(); var valueDescription=$this.find('p.description').text(); valueLabel=(valueLabel!==undefined) ? valueLabel.toLowerCase():'XXXXXXX'; valueDescription=(valueDescription!==undefined) ? valueDescription.toLowerCase():'XXXXXXX'; if(valueLabel.indexOf(searchTerm)===-1&&valueDescription.indexOf(searchTerm)===-1){ $this.addClass('hide-setting'); }else{ $this.closest('table').prevAll('h2:first').show(); $this.closest('.postbox-container').show(); $this.closest('.postbox-container').find('h2, .inside').show(); $this.closest('table').prevAll('#ai .icon_ai:first').show(); $this.closest('table').nextAll('p.button-submit:first').show(); $this.removeClass('hide-setting'); $this.closest('.hide-search').show(); if(searchTerm.length > 2){ var headerId=$this.closest('section').attr('class'); if(headerId!==undefined){ jQuery('#' + headerId).addClass('mark-tab-header'); if(firstHit===''){ firstHit=headerId; }} } found++; }}); if(found===0){ jQuery('#ai-input-search-result').show(); jQuery('#ai .mark-tab-header').removeClass('mark-tab-header'); }else{ jQuery('#ai-input-search-result').hide(); aiInstance&&aiInstance.revert(); if(searchTerm!==''&&searchTerm.length > 2){ var regex=RegExp(searchTerm, 'gi'); aiInstance=findAndReplaceDOMText(document.getElementById('tab_wrapper'), { find: regex, wrap: 'em' }); } jQuery('#' + firstHit).click(); }} function aiResizeIframeRatio(obj, ratio){ var width=jQuery('#' + obj.id).width(); var valueRatio=parseFloat(ratio.replace(',', '.')); var newHeight=Math.ceil(width * valueRatio); obj.height=newHeight; obj.style.height=newHeight + 'px'; } function aiGenerateShortcode(isPro){ var output='[advanced_iframe '; if(jQuery('#securitykey').val()!==''){ output +='securitykey="' + jQuery('#securitykey').val() + '" '; } output +='use_shortcode_attributes_only="true" '; var include_html_val=jQuery('#include_html').val(); var include_url_val=jQuery('#include_url').val(); var document_domain_add=jQuery('#document_domain_add').val(); if(include_html_val===undefined||(include_html_val===''&&include_url_val==='')){ var src=jQuery('#src').val(); if(src===''){ alert('Required url is missing.'); }else{ output +='src="' + src + '" '; } output +=aiGenerateTextShortcode('width'); output +=aiGenerateTextShortcode('height'); output +=aiGenerateRadioShortcode('scrolling','none'); output +=aiGenerateRadioShortcode('enable_ios_mobile_scolling','false'); output +=aiGenerateTextShortcode('marginwidth'); output +=aiGenerateTextShortcode('marginheight'); output +=aiGenerateTextShortcode('frameborder'); output +=aiGenerateRadioShortcode('transparency','true'); output +=aiGenerateTextShortcode('class'); output +=aiGenerateTextShortcode('style'); output +=aiGenerateTextShortcodeWithDefault('id', 'advanced_iframe'); output +=aiGenerateTextShortcode('name'); output +=aiGenerateRadioShortcode('allowfullscreen','false'); output +=aiGenerateTextShortcode('safari_fix_url'); output +=aiGenerateTextShortcode('url_forward_parameter'); output +=aiGenerateTextShortcode('map_parameter_to_url'); output +=aiGenerateRadioShortcode('add_iframe_url_as_param','false'); output +=aiGenerateTextShortcode('add_iframe_url_as_param_prefix'); output +=aiGenerateRadioShortcode('onload_scroll_top','false'); output +=aiGenerateRadioShortcode('hide_page_until_loaded','false'); output +=aiGenerateRadioShortcode('show_iframe_loader','false'); output +=aiGenerateTextShortcode('hide_content_until_iframe_color'); output +=aiGenerateTextShortcode('iframe_zoom'); output +=aiGenerateRadioShortcode('iframe_zoom_ie8', 'false'); output +=aiGenerateRadioShortcode('use_zoom_absolute_fix', 'false'); output +=aiGenerateRadioShortcode('auto_zoom', 'false'); output +=aiGenerateTextShortcode('auto_zoom_by_ratio'); output +=aiGenerateRadioShortcode('enable_responsive_iframe','false'); output +=aiGenerateTextShortcode('iframe_height_ratio'); output +=aiGenerateRadioShortcode('enable_lazy_load','false'); output +=aiGenerateTextShortcodeWithDefault('enable_lazy_load_threshold','3000'); output +=aiGenerateRadioShortcode('enable_lazy_load_reserve_space','true'); output +=aiGenerateTextShortcode('enable_lazy_load_fadetime'); output +=aiGenerateRadioShortcode('enable_lazy_load_manual','false'); output +=aiGenerateRadioShortcode('enable_lazy_load_manual_element','false'); output +=aiGenerateTextShortcode('reload_interval'); output +=aiGenerateTextShortcode('hide_elements'); output +=aiGenerateTextShortcode('content_id'); output +=aiGenerateTextShortcode('content_styles'); output +=aiGenerateTextShortcode('parent_content_css'); output +=aiGenerateRadioShortcode('add_css_class_parent','false'); output +=aiGenerateTextShortcode('change_parent_links_target'); output +=aiGenerateRadioShortcode('show_iframe_as_layer', 'false'); output +=aiGenerateRadioShortcode('show_iframe_as_layer_full', 'false'); output +=aiGenerateTextShortcode('show_iframe_as_layer_header_file'); output +=aiGenerateTextShortcodeWithDefault('show_iframe_as_layer_header_height','100'); output +=aiGenerateRadioShortcode('show_iframe_as_layer_header_position', 'top'); output +=aiGenerateRadioShortcode('show_iframe_as_layer_keep_content', 'true'); var showPartOfIframe=aiGenerateRadioShortcode('show_part_of_iframe','false'); output +=showPartOfIframe; if(showPartOfIframe!==''){ output +=aiGenerateTextShortcodeWithDefault('show_part_of_iframe_x',-1); output +=aiGenerateTextShortcodeWithDefault('show_part_of_iframe_y',-1); output +=aiGenerateTextShortcode('show_part_of_iframe_width'); output +=aiGenerateTextShortcode('show_part_of_iframe_height'); output +=aiGenerateTextShortcode('show_part_of_iframe_media_query'); output +=aiGenerateRadioShortcode('show_part_of_iframe_allow_scrollbar_horizontal','false'); output +=aiGenerateRadioShortcode('show_part_of_iframe_allow_scrollbar_vertical','false'); output +=aiGenerateTextShortcode('show_part_of_iframe_style'); output +=aiGenerateRadioShortcode('show_part_of_iframe_zoom','false'); output +=aiGenerateTextShortcode('show_part_of_iframe_next_viewports'); output +=aiGenerateRadioShortcode('show_part_of_iframe_next_viewports_loop','false'); output +=aiGenerateTextShortcode('show_part_of_iframe_new_window'); output +=aiGenerateTextShortcode('show_part_of_iframe_new_url'); output +=aiGenerateRadioShortcode('show_part_of_iframe_next_viewports_hide','false'); } output +=aiGenerateTextShortcode('hide_part_of_iframe'); output +=aiGenerateRadioShortcode('add_css_class_iframe','false'); output +=aiGenerateTextShortcode('iframe_hide_elements'); output +=aiGenerateTextShortcode('onload_show_element_only'); output +=aiGenerateTextShortcode('iframe_content_id'); output +=aiGenerateTextShortcode('iframe_content_styles'); output +=aiGenerateTextShortcode('iframe_content_css'); output +=aiGenerateTextShortcode('change_iframe_links'); output +=aiGenerateTextShortcode('change_iframe_links_target'); output +=aiGenerateTextShortcode('change_iframe_links_href'); output +=aiGenerateTextShortcode('onload'); output +=aiGenerateRadioShortcode('onload_resize','false'); output +=aiGenerateTextShortcode('onload_resize_delay'); output +=aiGenerateRadioShortcode('store_height_in_cookie','false'); output +=aiGenerateTextShortcode('additional_height'); output +=aiGenerateRadioShortcode('onload_resize_width','false'); output +=aiGenerateTextShortcode('resize_on_ajax'); output +=aiGenerateRadioShortcode('resize_on_ajax_jquery','true'); output +=aiGenerateTextShortcode('resize_on_click'); output +=aiGenerateTextShortcodeWithDefault('resize_on_click_elements','a'); output +=aiGenerateTextShortcode('resize_on_element_resize'); output +=aiGenerateTextShortcodeWithDefault('resize_on_element_resize_delay','250'); output +=aiGenerateTextShortcode('tab_hidden'); output +=aiGenerateTextShortcode('tab_visible'); output +=aiGenerateRadioShortcode('add_document_domain','false'); if(document_domain_add==='true'){ output +=aiGenerateTextShortcode('document_domain'); } output +=aiGenerateRadioShortcode('enable_external_height_workaround','external'); output +=aiGenerateRadioShortcode('hide_page_until_loaded_external','false'); output +=aiGenerateTextShortcode('pass_id_by_url'); if(isPro==='true'){ output +=aiGenerateRadioShortcode('multi_domain_enabled','true'); output +=aiGenerateRadioShortcode('use_post_message','true'); }else{ output +=aiGenerateRadioShortcode('multi_domain_enabled','false'); output +=aiGenerateRadioShortcode('use_post_message','false'); } output +=aiGenerateTextShortcode('additional_css'); output +=aiGenerateTextShortcode('additional_js'); output +=aiGenerateTextShortcode('additional_js_file_iframe'); output +=aiGenerateTextShortcode('additional_css_file_iframe'); }else{ if(include_html_val===''){ output +=aiGenerateTextShortcode('include_url'); output +=aiGenerateTextShortcode('include_content'); output +=aiGenerateTextShortcode('include_height'); output +=aiGenerateTextShortcode('include_fade'); output +=aiGenerateRadioShortcode('include_hide_page_until_loaded','false'); }else{ output +=aiGenerateTextShortcode('include_html'); }} output +=aiGenerateRadioShortcode('debug_js','false'); output=output.slice(0, -1); output +=']'; jQuery('#gen-shortcode').html(output); } function aiGenerateTextShortcodeWithDefault(field, defaultValue){ var output=''; var value=jQuery('#' + field); var val=value.val(); if(value.length > 0&&val!==''&&val!==defaultValue){ output=field + '="' + val + '" '; } return output; } function aiGenerateTextShortcode(field){ var output=''; var value=jQuery('#' + field); var val=value.val(); if(value.length > 0&&val!==''&&val!=='0'){ output=field + '="' + val + '" '; } return output; } function aiGenerateRadioShortcode(field, defaultValue){ var output=''; var value=jQuery('input:radio[name='+field+']:checked'); var val=value.val(); if(field==='enable_ios_mobile_scolling'){ field='enable_ios_mobile_scrolling'; } if(value.length > 0&&val!==defaultValue){ output +=field + '="' + val + '" '; } return output; } function aiAddCssClassAllParents(element){ var parents=jQuery(element).parentsUntil('html'); var ai_class='ai-class-'; for(var i=0; i < parents.length; i++){ var id=jQuery(parents[i]).attr('id'); if(typeof id!=='undefined'){ if(id.indexOf('ai-')!==0){ jQuery(parents[i]).addClass(ai_class + id); }}else{ jQuery(parents[i]).addClass(ai_class + i); }} } function aiAutoZoomExternalHeight(id, width, height, responsive){ var parentWidth=aiAutoZoomExternal(id, width, responsive); var zoomRatio=window['zoom_' + id]; var oldScrollposition=jQuery(document).scrollTop(); var newHeight=Math.ceil(height*zoomRatio); jQuery('#ai-zoom-div-' + id).css('height', newHeight); jQuery("html,body").scrollTop(oldScrollposition); return parentWidth; } function aiAutoZoomExternal(id, width, responsive){ var obj=document.getElementById(id); var objAround=document.getElementById('ai-zoom-div-' +id); var jObj=jQuery('#' + id); if(responsive==='true'){ jObj.css('max-width', '100%'); } var iframeWidth=width; var parentWidth=aiGetParentIframeWidth(obj); if(parentWidth===iframeWidth){ parentWidth=aiGetParentIframeWidth(objAround); } var zoomRatio=parentWidth / iframeWidth; var zoomRatioRounded=Math.floor(zoomRatio * 100) / 100; if(zoomRatioRounded > 1){ zoomRatioRounded=1; } aiSetZoom(id, zoomRatioRounded); window['zoom_' + id]=zoomRatioRounded; jObj.width(iframeWidth).css('max-width', 'none'); return parentWidth; } function aiAutoZoom(id, responsive, ratio){ var parts=ratio.split('|'); ratio=parts[0]; var width=-1; if(parts.length!==1){ width=parts[1]; } var obj=document.getElementById(id); var iframeWidth; if(width===-1){ obj.width=1; obj.style.width='1px'; iframeWidth=aiGetIframeWidth(obj); obj.width=iframeWidth; obj.style.width=iframeWidth + 'px'; }else{ iframeWidth=width; } var parentWidth=aiAutoZoomExternal(id, iframeWidth, responsive); if(ratio===''){ aiResizeIframe(obj, false); }else{ var newheight=Math.ceil(iframeWidth * ratio); obj.height=newheight; obj.style.height=newheight + 'px'; if(jQuery('#ai-zoom-div-' + obj.id).length!==0){ var zoom=window['zoom_' + obj.id]; jQuery('#ai-zoom-div-' + obj.id).css('height', Math.ceil(newheight * zoom)); }} return parentWidth; } function aiSetZoom(id, zoom){ var obj=jQuery('#' + id); if(aiIsIe8===true){ obj.css('-ms-zoom', zoom); } obj.css({ '-ms-transform': 'scale(' + zoom + ')', '-moz-transform': 'scale(' + zoom + ')', '-o-transform': 'scale(' + zoom + ')', '-webkit-transform': 'scale(' + zoom + ')', 'transform': 'scale(' + zoom + ')' }); } function aiAutoZoomViewport(id, full){ var viewportDiv=jQuery(id); var outerDiv=viewportDiv.parent(); var counter=0; while (outerDiv.is('p')||(outerDiv.attr('id')!==undefined&&outerDiv.attr('id').indexOf('ai-')===0)){ outerDiv=outerDiv.parent(); if(counter++ > 10){ alert('Unexpected div structure. Please disable the zoom.'); break; }} var viewportDivWidth=viewportDiv.width(); var outer_div_width=outerDiv.width(); var viewportDivHeight=viewportDiv.height(); var zoom=outer_div_width / viewportDivWidth; if(full==='true'&&zoom > 1){ zoom=1; } aiSetZoom(viewportDiv.attr('id'), zoom); var marginLeft=-Math.round((viewportDivWidth - viewportDivWidth * zoom) / 2); var marginTop=-Math.round((viewportDivHeight - viewportDivHeight * zoom) / 2); viewportDiv.css({ 'margin-left': marginLeft + 'px', 'margin-right': marginLeft + 'px', 'margin-top': marginTop + 'px', 'margin-bottom': marginTop + 'px' }); } function aiResetAiSettings(){ jQuery('#action').val('reset'); } function aiCheckInputNumber(inputField){ inputField.value=inputField.value.split(' ').join(''); var f=inputField.value; if(inputField.value===''){ return; } var match=f.match(/^(\-){0,1}([\d.])+(px|%|em|pt|vh|vw|rem|ch)?(\-|\+){0,1}([\d.]){0,7}(px|%|em|pt|vh|vw|rem|ch)?$/); if(!match){ alert('Please check the value you have entered. Only numbers with a dot or with an optional px, %, em or pt are allowed.'); setTimeout(function(){inputField.focus();}, 10); }} function aiCheckInputNumberOnly(inputField){ inputField.value=inputField.value.split(' ').join(''); var f=inputField.value; if(inputField.value===''){ inputField.value='0'; return; } var match=f.match(/^(\-){0,1}([\d.])+$/); if(!match){ alert('Please check the value you have entered. Only numbers without a dot or optional px, %, em or pt are allowed.'); setTimeout(function(){inputField.focus();}, 10); }} function aiShowHeader(id, element){ var y=jQuery(window).scrollTop(); jQuery(window).scrollTop(y-40); if(element!==undefined){ aiFlashElement(element); }} function aiFlashElement(element){ setTimeout(function(){ jQuery('#' +element).css('background-color','#eee'); } , 500); setTimeout(function(){ jQuery('#' +element).css('background-color','#fff'); } , 900); setTimeout(function(){ jQuery('#' +element).css('background-color','#eee'); } , 1300); setTimeout(function(){ jQuery('#' +element).css('background-color','#fff'); } , 1700); } function aiSetScrollposition(){ var scrollposition=jQuery(document).scrollTop(); jQuery('#scrollposition').val(scrollposition); } function aiResetShowPartOfAnIframe(id){ jQuery('#' + id).css('top','0px').css('left','0px').css('position','static'); jQuery('#ai-div-' + id).css('width','auto').css('height','auto').css('overflow','auto').css('position','static'); } function aiShowLayerIframe(event, id, path, hideUntilLoaded, showLoadingIcon, keep, reload){ keep=(keep===undefined) ? false:keep; reload=(reload===undefined) ? true:reload; var layerId='#' + id; jQuery('#ai-zoom-div-' + id).show(); if(reload&&hideUntilLoaded==='true'){ jQuery(layerId).css('visibility', 'hidden'); } jQuery(layerId).show(); if(jQuery('#ai-layer-div-' + id).length){ layerId='#ai-layer-div-' + id; jQuery(layerId).show(); } jQuery('body').css('overflow','hidden'); jQuery('html').css('overflow-y','visible'); jQuery('body').append(''); var icon=''; if(reload&&showLoadingIcon==='true'){ icon='
Loading
'; } jQuery(layerId).parent().append('
' + icon); jQuery('#ai_backlink, #ai_backlayer').click(function(){ aiHideLayerIframe(id, keep); }); if(!reload){ event.preventDefault(); event.stopPropagation(); }} function aiHideLayerIframe(id, keep){ jQuery('#' + id).hide(); if(!keep){ jQuery('#' + id).attr('src', 'about:blank'); aiLayerIframeHrefs[id]='about:blank'; } jQuery('#ai-zoom-div-' + id).hide(); jQuery('#ai-layer-div-' + id).hide(); jQuery('#ai_backlink').remove(); jQuery('#ai_backlayer').remove(); jQuery('#ai-div-loader-global').remove(); jQuery('body').css('overflow','auto'); jQuery('html').css('overflow-y','scroll'); } var aiLayerIframeHrefs=[]; function aiCheckReload (link, id){ var iframeSrc; if(typeof aiLayerIframeHrefs[id]==='undefined'){ iframeSrc=jQuery('#' + id).attr('src'); }else{ iframeSrc=aiLayerIframeHrefs[id]; } var linkHref=jQuery(link).attr('href'); aiLayerIframeHrefs[id]=linkHref; return (iframeSrc!==linkHref); } function aiChangeUrlParam(loc, param, orig, prefix){ var newUrl; if(loc!==encodeURIComponent(orig)){ newUrl=aiSetGetParameter(param, loc); var removeProtocol=true; if(prefix==='hash'||prefix==='hashrewrite'){ var locBase=aiRemoveQueryString(loc); return aiGetUrlMapping(locBase, param, prefix); }else if(prefix){ var repUrl=newUrl.replace(prefix,''); if(repUrl===newUrl){ removeProtocol=false; } newUrl=repUrl; } if(removeProtocol){ newUrl=newUrl.replace('http%3A%2F%2F',''); if(window.location.href.toLowerCase().lastIndexOf("http:", 0)!==-1){ newUrl=newUrl.replace('https%3A%2F%2F','s|'); }else{ newUrl=newUrl.replace('https%3A%2F%2F',''); }} }else{ var fullUrl=window.location.href; fullUrl=fullUrl.split("/" + param + "/",1)[0]; newUrl=aiRemoveURLParameter(fullUrl, param); } aiSetBrowserUrl(newUrl); } function aiGetUrlMappingUrl(locBase, param, prefix, id){ var fullUrl=window.location.href; newUrl=aiRemoveURLParameter(fullUrl, param); if(prefix==='hash'){ var seperator=(newUrl.indexOf('?') >=0) ? '&':'?'; newUrl +=seperator+param+"=" + id; }else{ var queryString="/"; if(newUrl.indexOf('?') >=0){ var newUrlArray=newUrl.split('?'); newUrl=newUrlArray[0]; queryString='/?' + newUrlArray[1]; } var baseUrl=newUrl.split("/" + param + "/",1)[0]; if(!aiEndsWidth(baseUrl, "/")){ baseUrl +='/'; } newUrl=baseUrl + param+"/" + id + queryString; } return newUrl; } function aiSetBrowserUrl(newUrl){ if(aiSupportsHistoryApi()){ newUrl=newUrl.replace(/%2F/g,'/'); window.history.pushState({}, '', newUrl); window.onpopstate=function(event){ if(event&&event.state){ window.history.back(); }};}} function aiRemoveQueryString(loc){ if(loc.indexOf('%3F') >=0){ return loc.split('%3F')[0]; }else{ return loc; }} function aiGetUrlMapping(url, param, prefix){ var data={ action: 'aip_map_url_action', security:MyAjax.security, url: url }; jQuery.post(MyAjax.ajaxurl, data, function(id){ var newUrl=aiGetUrlMappingUrl(url, param, prefix, id); aiSetBrowserUrl(newUrl); }); } function closeInfoPermanent(id){ var data={ action: 'aip_close_message_permanent', security:MyAjax.security, id: id }; jQuery.post(MyAjax.ajaxurl, data, function(id){ jQuery('h1').after('

The message before will only appear again when you reset the settings.

'); }); setTimeout(function(){ jQuery(".message-notice").fadeOut() }, 4000); } function aiSupportsHistoryApi(){ return !!(window.history&&history.pushState); } function aigetIframeLocation(id){ try { var location=document.getElementById(id).contentWindow.location; return encodeURIComponent(location); } catch(e){ if(console&&console.log){ console.log('Advanced iframe configuration error: You have enabled to add the url to the url on the same domain. But you use an iframe page on a different domain. You need to use the pro version of the external workaround like described in the settings. Also check the next log. There the browser message for this error is displayed.'); console.log(e); }} } function aiSetGetParameter(paramName, paramValue){ var url=window.location.href; var splitAtAnchor=url.split('#'); url=splitAtAnchor[0]; var anchor=typeof splitAtAnchor[1]==='undefined' ? '':'#' + splitAtAnchor[1]; if(url.indexOf(paramName + '=') >=0){ var prefix=url.substring(0, url.indexOf(paramName+ '=')); var suffix=url.substring(url.indexOf(paramName+ '=')); suffix=suffix.substring(suffix.indexOf('=') + 1); suffix=(suffix.indexOf('&') >=0) ? suffix.substring(suffix.indexOf('&')):''; url=prefix + paramName + '=' + paramValue + suffix; }else{ if(url.indexOf('?') < 0){ url +='?' + paramName + '=' + paramValue; }else{ url +='&' + paramName + '=' + paramValue; }} return url + anchor; } function aiRemoveURLParameter(url, parameter){ var urlparts=url.split('?'); if(urlparts.length>=2){ var prefix=encodeURIComponent(parameter)+'='; var pars=urlparts[1].split(/[&;]/g); for (var i=pars.length; i-- > 0;){ if(pars[i].lastIndexOf(prefix, 0)!==-1){ pars.splice(i, 1); }} if(pars.length!==0){ url=urlparts[0]+'?'+pars.join('&'); }else{ url=urlparts[0]; } return url; }else{ return url; }} function aiEndsWidth(string, target){ return string.substr(-target.length)===target; } function aiAddCss(id,css){ css=decodeURIComponent(css.replace(/\+/g, '%20')); var body=jQuery(id).contents().find('body'); var s=document.createElement('style'); s.setAttribute('type', 'text/css'); if(s.styleSheet){ s.styleSheet.cssText=css; }else{ s.appendChild(document.createTextNode(css)); } body.append(s); } function aiAddCssFile(id, filename){ var body=jQuery(id).contents().find('body'); var link=document.createElement('link'); link.rel='stylesheet'; link.type='text/css'; link.href=filename; body.append(link); } function aiAddJsFile(id, filename){ jQuery.ajaxSetup({ cache:true}); var body=jQuery(id).contents().find('body'); var script=document.createElement('script'); script.type='text/javascript'; script.src=filename; body.append(script); } function aiPresetFullscreen(){ jQuery('#style').val('position:fixed;z-index:9000;top:0px;left:0px;margin:0px'); jQuery('#width').val('100%'); jQuery('#height').val('100%'); jQuery('#content_id').val('html,body'); jQuery('#content_styles').val('overflow:hidden'); jQuery('#hide_content_until_iframe_color').val('#ffffff'); } jQuery(document).ready(function(){ jQuery('iframe').parent('p').css('margin','0'); aiWindowWidth=jQuery(window).width(); jQuery.each(aiReadyCallbacks, function(index, callback){ callback(); }); setTimeout(function(){ jQuery("#ai #ai-updated-text").css("visibility","hidden")}, 4000); jQuery('#ai #checkIframes').on('click', function(){ jQuery('.ai-spinner').css('display','inline-table'); jQuery(this).addClass('disabled'); setTimeout(aiDisableCheckIframes, 200); }); var moved=false; jQuery('#aiDebugDivTotal').mousedown(function(){moved=false;}).mousemove(function(){moved=true;}).mouseup(function(event){ if(!moved){ var elem=jQuery('#aiDebugDiv'); if(Math.floor(elem.height()) > '300'){ elem.height('0px'); }else{ elem.height('400px'); }} }); if(typeof ai_show_id_only!=='undefined'){ if(jQuery('#' + ai_show_id_only).length===0){ alert('The element with the id "' + ai_show_id_only + '" cannot be found. Please check your configuration.'); }else{ var element=jQuery('#' + ai_show_id_only); element.siblings().hide(); var parents=element.parents(); parents.siblings().hide(); parents.css('padding', '0px').css('margin', '0px').css('overflow', 'hidden'); if(parent===top){ var elementRaw=element[0]; elementRaw.style.marginTop=elementRaw.style.marginBottom=0; elementRaw.style.overflow="hidden"; var newHeightRaw=Math.max(elementRaw.scrollHeight, elementRaw.offsetHeight); var newHeight=parseInt(newHeightRaw,10); var data={ 'aitype':'height', 'height':newHeight, 'id':ai_show_id_only}; var json_data=JSON.stringify(data); parent.postMessage(json_data, '*'); }} }}); function aiDisableCheckIframes(){ var input=jQuery("").attr("type", "hidden").attr("name", "checkIframes").val("true"); jQuery("#ai_form").append(input); jQuery("#ai_form").submit(); jQuery('#checkIframes').prop('disabled','disabled'); } function aiProcessMessage(event,id,debug){ var jsObject; try { var jsObject=JSON.parse(event.data); } catch(e){ if(debug==='debug'&&console&&console.log){ console.log('The received message cannot be parsed and seems not to belong to advanced iframe pro. Please disable the postMessage debug mode if this o.k. and that this message is not shown anymore.'); console.log(e); } var jsObject=event.data; } try { if(jsObject.hasOwnProperty('aitype')){ if(id===jsObject.id){ var type=jsObject.aitype; if(type==='debug'){ aiProcessDebug(jsObject); }else if(type==='scrollToTop'){ aiProcessScrollToTop(jsObject); }else{ if(type==='height'){ aiProcessHeight(jsObject); }else if(type==='show'){ aiProcessShow(jsObject); } for (var key in jsObject.data){ if(jsObject.data.hasOwnProperty(key)){ jQuery(key).html(jsObject.data[key]); }} }} }} catch(e){ if(debug==='debug'&&console&&console.log){ console.log('The received message do not belong to advanced iframe pro. Please disable the postMessage debug mode if this o.k. and that this message is not shown anymore.'); console.log(e); }} } function aiProcessDebug(jsObject){ var debugData=jsObject.data; if(jQuery('#aiDebugDiv').length!==0){ debugData=debugData.replace(/&/g, "&").replace(//g, ">"); debugData=debugData.replace('\"', '"').replace(/\\/g,""); jQuery('#aiDebugDiv').append('

r: ' + debugData + '

'); }} function aiProcessScrollToTop(jsObject){ var id=jsObject.id; aiScrollToTop(id, aiOnloadScrollTop); } function aiProcessHeight(jsObject){ var nHeight=jsObject.height; var nWidth=jsObject.width; var iAnchor=parseInt(jsObject.anchor,10); var id=jsObject.id; if(nHeight!=null){ try { var loc=jsObject.loc; if(loc!=null){ aiChangeUrl(loc); } if(id!=null){ var iHeight=parseInt(nHeight,10); var iWidth=parseInt(nWidth,10); aiResizeIframeHeightId(iHeight,iWidth, id); if(!isNaN(iAnchor)&&iAnchor > -1){ var iframeTop=jQuery("#" + id).offset().top; setTimeout(function(){ jQuery("html,body").scrollTop(Math.round(iframeTop + iAnchor)); aiShowIframeId(id); }, 100); }else{ aiShowIframeId(id); }}else{ alert('Please update the ai_external.js to the current version.'); }} catch(e){ if(console&&console.log){ console.log(e); }} }} function aiProcessShow(jsObject){ var id=jsObject.id; try { aiShowIframeId(id); } catch(e){ if(console&&console.log){ console.log(e); }} } function aiRemoveElementsFromHeight(id,height,removeElements){ var iframe=jQuery('#' + id); var elementArray=removeElements.split(','); var totalHeight=0; for (var i=0; i < elementArray.length; i++){ try { var el=elementArray[i]; if(el.includes("|")){ var rangeArray=el.split('|'); var bottomElement=jQuery(rangeArray[0]); var beforeBottom=Math.round(bottomElement.offset().top + bottomElement.outerHeight(true)); var nextTop=Math.round(jQuery(rangeArray[1]).offset().top); totalHeight +=nextTop - beforeBottom; }else if(el==='top'){ totalHeight +=Math.round(jQuery('#' + id).offset().top); }else if(isNaN(el)){ totalHeight +=jQuery(el).outerHeight(true); }else{ totalHeight +=parseInt(el); }} catch(e){ if(console&&console.log){ console.log('Advanced iframe configuration error: The configuration of remove_elements_from_height "'+removeElements+'" is invalid. Please check if the elements you defined do exist and ids/classes are defined properly.'); console.log(e); }} } var calc='calc(' + height + ' - ' + totalHeight + 'px)'; iframe.css('height', calc); } if(!String.prototype.includes){ String.prototype.includes=function(search, start){ if(typeof start!=='number'){ start=0; } if(start + search.length > this.length){ return false; }else{ return this.indexOf(search, start)!==-1; }};};